<!DOCTYPE html>
<html lang="en">

<head>
    <title>3D Web Homework</title>
    <meta charset=utf-8 />
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            height: 100vh;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        #login {
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            padding: 20px;
            border-radius: 15px;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
            text-align: center;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        #login h2 {
            margin-top: 0;
            color: white;
        }

        #login .input-group {
            display: flex;
            gap: 10px;
            align-items: center;
        }

        #login .input-group label {
            color: white;
            width: 80px;
            text-align: right;
        }

        #login input,
        #login button {
            padding: 10px;
            margin: 5px;
            border: none;
            border-radius: 5px;
        }

        #login button {
            background: #4CAF50;
            color: white;
            cursor: pointer;
        }

        #login .button-group {
            display: flex;
            gap: 10px;
            justify-content: center;
        }

        #chat {
            display: none;
            width: 100%;
            height: 100%;
            position: relative;
            padding: 20px;
            box-sizing: border-box;
        }

        #messages {
            position: absolute;
            left: 20px;
            bottom: 80px;
            width: 250px;
            height: 150px;
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            border-radius: 15px;
            padding: 15px;
            overflow-y: scroll;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
        }

        #user-list {
            position: absolute;
            left: 20px;
            top: 150px;
            width: 150px;
            height: 200px;
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            border-radius: 15px;
            padding: 15px;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
            overflow-y: auto;
        }

        #user-list ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        #user-list li {
            padding: 5px 0;
            color: white;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        #user-list li:hover {
            background: rgba(255, 255, 255, 0.1);
            cursor: pointer;
        }

        #user-list h3 {
            margin-top: 0;
            color: white;
        }

        #message-container {
            position: fixed;
            bottom: 20px;
            left: 0;
            right: 0;
            display: flex;
            justify-content: center;
            gap: 10px;
            padding: 0 20px;
        }

        #message {
            flex: 1;
            max-width: 70%;
            padding: 10px;
            border: none;
            border-radius: 5px;
            background: rgba(255, 255, 255, 0.8);
        }

        #chat button {
            padding: 10px 20px;
            background: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        @media (max-width: 300px) {

            #messages,
            #user-list {
                width: 90%;
            }

            #user-list {
                height: 20%;
            }
        }

        .chatbox {
            grid-area: chatbox;
            border: 1px solid black;
            margin: 0;
            overflow-y: scroll;
            padding: 1px;
            padding: 0.1rem 0.5rem;
        }

        .camerabox {
            grid-area: camerabox;
            width: 500px;
            height: 375px;
            border: 1px solid black;
            vertical-align: top;
            display: block;
            position: fixed;
            bottom: 80px;
            right: 20px;
            overflow: auto;
        }

        /* The small "preview" view of your camera */
        #local_video {
            width: 120px;
            height: 90px;
            position: absolute;
            top: 1rem;
            left: 1rem;
            border: 1px solid rgba(255, 255, 255, 0.75);
            box-shadow: 0 0 4px black;
        }

        /* The "Hang up" button */
        #hangup-button {
            display: block;
            width: 80px;
            height: 24px;
            border-radius: 8px;
            position: relative;
            margin: auto;
            top: calc(100% - 40px);
            background-color: rgba(150, 0, 0, 0.7);
            border: 1px solid rgba(255, 255, 255, 0.7);
            box-shadow: 0px 0px 1px 2px rgba(0, 0, 0, 0.4);
            font-size: 14px;
            font-family: "Lucida Grande", "Arial", sans-serif;
            color: rgba(255, 255, 255, 1.0);
            cursor: pointer;
        }

        #hangup-button:hover {
            filter: brightness(150%);
            -webkit-filter: brightness(150%);
        }

        #hangup-button:disabled {
            filter: grayscale(50%);
            -webkit-filter: grayscale(50%);
            cursor: default;
        }
    </style>
</head>

<body>
    <div id="login">
        <h2>登录</h2>
        <div class="input-group">
            <label for="serverAddress">服务器:</label>
            <input type="text" id="serverAddress" placeholder="服务器地址" value="ws://localhost:8080">
        </div>
        <div class="input-group">
            <label for="username">用户名:</label>
            <input type="text" id="username" placeholder="输入用户名">
        </div>
        <div class="button-group">
            <button id="loginButton">登录</button>
            <a href="examples.html"
                style="display: inline-block; padding: 10px; background: #2196F3; color: white; border: none; border-radius: 5px; cursor: pointer; text-decoration: none;">查看示例</a>
        </div>
    </div>

    <div id="chat">
        <div id="info"
            style="position: fixed; top: 50px; left: 50%; transform: translate(-50%, -50%); background: rgba(255,255,255,0.2); backdrop-filter: blur(10px); padding: 15px; border-radius: 15px; color: white; text-align: center; z-index: 100;">
            Octree threejs demo - basic collisions with static triangle mesh<br />
            MOUSE to look around and to throw balls<br />
            WASD to move and SPACE to jump
        </div>
        <div id="container" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>

        <div id="message-container">
            <input type="text" id="message" placeholder="输入消息">
            <button id="sendButton">发送</button>
        </div>
        <div id="messages">
        </div>
        <div id="user-list">
            <h3>在线用户</h3>
            <ul id="users"></ul>
        </div>

        <div id="camerabox" class="camerabox">
            <video id="received_video" autoplay></video>
            <video id="local_video" autoplay muted></video>
            <button id="hangup-button" onclick="hangUpCall();" role="button" disabled>
                Hang Up
            </button>
            <button id="videoBtn" onclick="onVideoBtn();" style="position:relative;">
                视频开关
            </button>
            <button id="audioBtn" onclick="onAudioBtn();" style="position:relative;">
                音频开关
            </button>
            <button id="remoteVideoBtn" onclick="onRemoteVideoBtn();" style="position:relative;">
                屏蔽视频开关
            </button>
            <button id="remoteAudioBtn" onclick="onRemoteAudioBtn();" style="position:relative;">
                屏蔽音频开关
            </button>
        </div>
    </div>

    <script type="module" src="./src/index.ts"></script>
</body>

</html>